//账单记录
$(function(){
		var token=sessionStorage.getItem("token");
		var method ="Withdraw|withdraw_list";
		var pagesize="6";
		
                var xx=$("#txmx").attr("data-xx");
                var p=1;
                if(xx!=="xx"){
                    mxMore();
                    
                    $(".More").click(function(){
                            p+=1;
                            $(this).attr("disabled","true");
                            setTimeout(function(){
                                    $('.More').removeAttr("disabled");
                            },2000);
                            mxMore(p);
                    })
       
                }else{
                     xxMore();
                    
                    $(".More").click(function(){
                            p+=1;
                            $(this).attr("disabled","true");
                            setTimeout(function(){
                                    $('.More').removeAttr("disabled");
                            },2000);
                            xxMore(p);
                    })
                }
	function mxMore(p){
		if(!p){
			p="1";
		}
		var d={};
		d.token=token;
		d.method=method;
		d.p=p+"";
		d.pagesize=pagesize;
		$.ajax({
			type:"post",
			url:"http://www.rice.com/app/api/h5_access",
			data:d,
			dataType:"json",
			success:function(result){
                                
				if(result.status=="1"){
					var data=result.data.order_data;
					var sttr=$("#txmx").html();
                                        if(data==""){
                                            alert("没有更多数据");
                                            return false;
                                        }
					for(var i=0;i<data.length;i++){
                                            var hh=data[i].add_time;
                                            var date = new Date(hh*1000);
                                            var Y = date.getFullYear() + '-';
                                            var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
                                            var D = (date.getDate()< 10 ? '0'+(date.getDate()) :date.getDate())+ ' ';
                                            var h = (date.getHours()< 10 ? '0'+(date.getHours()) :date.getHours())+ ':';
                                            var m = (date.getMinutes()< 10 ? '0'+(date.getMinutes()) :date.getMinutes())+':';
                                            var s = (date.getSeconds()< 10 ? '0'+(date.getSeconds()) :date.getSeconds());
                                                sttr+='<div style="position: relative;padding: 10px;cursor: pointer;" class="tmx" data-id="'+data[i].order_id+'">';
                                                sttr+=' <img src="img/Withdrawal_details1.png"  width="100%" />';
						sttr+='<div style="position: absolute;z-index: 100;top: 23%;left: 24%;"><span style="font-size: 16px; color: #fff;">'+data[i].type_name+'¥ '+data[i].amount+'</span></div>';
						sttr+='<div style="position: absolute;z-index: 100;top: 23%;left: 83%;"><span style="font-size: 16px; color: #fff;">删除</span></div>';
						sttr+='<div style="position: absolute;z-index: 100;top: 62%;left: 24%;"><span style="font-size: 13px; color: #fff;">'+Y+M+D+h+m+s+'尾号('+data[i].bank_no+')</span></div>';
                                                sttr+='<div style="position: absolute;z-index: 100;top: 45%;left: 76%;"><span style="font-size: 16px; color: #fff;">'+data[i].status_name+'</span></div>';
						sttr+='</div>';            
					};
					$("#txmx").html(sttr);
                                                     $(".tmx").click(function(){
                                                        var order_id=$(this).attr("data-id");
                                                        sessionStorage.setItem("order_id",order_id);
                                                        location.href="bill1.html";
                                                    })
				}else if(result.status=="2"){
                                    alert(result.message);
                                    location.href="login.html";
                                }else{
                                    alert(result.message);
                                }
			}
		});
	}
        function xxMore(p){
		if(!p){
			p="1";
		}
		var d={};
		d.token=token;
		d.method="balancerecord";
		d.p=p+"";
		d.pagesize=pagesize;
                console.log(d);
		$.ajax({
			type:"post",
			url:"http://www.rice.com/app/api/h5_access",
			data:d,
			dataType:"json",
			success:function(result){
                                console.log(1);
				if(result.status=="1"){
					var data=result.data.data;
					var sttr=$("#txmx").html();
                                        if(data==""){
                                               alert("没有更多数据");
                                            return false;
                                        }
					for(var i in data){
                                            var hh=data[i].created_time;
                                            var date = new Date(hh*1000);
                                            var Y = date.getFullYear() + '-';
                                            var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
                                            var D = (date.getDate()< 10 ? '0'+(date.getDate()) :date.getDate())+ ' ';
                                            var h = (date.getHours()< 10 ? '0'+(date.getHours()) :date.getHours())+ ':';
                                            var m = (date.getMinutes()< 10 ? '0'+(date.getMinutes()) :date.getMinutes())+':';
                                            var s = (date.getSeconds()< 10 ? '0'+(date.getSeconds()) :date.getSeconds());
                                                sttr+='<div style="position: relative;padding: 10px;cursor: pointer;" class="tmx" data-id="'+data[i].orderid+'">';
                                                sttr+=' <img src="img/Withdrawal_details1.png"  width="100%" />';
						sttr+='<div style="position: absolute;z-index: 100;top: 10%;left: 24%;"><span style="font-size: 16px; color: #fff;">提现 ¥ '+data[i].amount+'</br>到账金额 ￥'+data[i].trueamount+'</span></div>';
						sttr+='<div style="position: absolute;z-index: 100;top: 23%;left: 83%;"><span style="font-size: 16px; color: #fff;">删除</span></div>';
						sttr+='<div style="position: absolute;z-index: 100;top: 62%;left: 24%;"><span style="font-size: 13px; color: #fff;">'+Y+M+D+h+m+s+'尾号('+data[i].bank_no+')</span></div>';
                                                sttr+='<div style="position: absolute;z-index: 100;top: 45%;left: 76%;"><span style="font-size: 16px; color: #fff;">'+data[i].status+'</span></div>';
						sttr+='</div>';            
					};
					$("#txmx").html(sttr);
				}else if(result.status=="2"){
                                    alert(result.message);
                                    location.href="login.html";
                                }else{
                                    alert(result.message);
                                }
			}
		});
	}
})
